<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>预处理错误日志</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@ include file="/pages/common/header.jsp"%>
<script type="text/javascript" src="<%=request.getContextPath() %>/js/datePicker/WdatePicker.js"></script>
<script type="text/javascript">
var gridManager;
var _dialog;
$(function (){
	
	gridManager = PageLoader.initGridPanel();
	
	var myDate=new Date();
	var year =myDate.getFullYear();
	var month =myDate.getMonth()+1;
	if(month<10){
		month="0"+month;
	}
	var day=myDate.getDate();
	if(day<10){
		day="0"+day;
	}
	var hours =myDate.getHours();
	var startTime=year+"-"+month+"-"+day;
	var stopTime=startTime;
	if(hours<10){
		//startTime +=" 0"+hours;
		stopTime +=" 0"+hours;
	}else{
		//startTime +=" "+hours;
		stopTime +=" "+hours;
	}
	startTime+=" 00";
	$("#start_ID").val(startTime);
	$("#end_ID").val(stopTime);
	
  var selectUrl="<%=contextPath %>/preprocess-FetlErrorMessage-nameMapSelect.action";
	
	$.ajax({
			url: selectUrl,
			type: 'POST',
			dataType: 'json',
			timeout: 1000,
			error: function(){
				alert('预处理请求出错');
			},
			success: function(json){
				$('#code_ID').html('');
				$('#code_ID').append('<option value="">请选择预处理类型</option>' );
				$.each(json.data, function(k, v){
					$('#code_ID').append('<option value='+k+'>'+v+'</option>' );
				});
			}

		});
	
});

PageLoader = {

 initGridPanel:function(){
	 var g = $("#maingrid").ligerGrid({
         checkbox:true,
         height : '100%',
         rowHeight: 28,//行默认的高度
         headerRowHeight: 30,//表头行的高度
         pageSize : 20,
         onToNext:next,//条件查询方法
         columns: [
                   { display: '预处理类型', name: 'fetlName', width : 160, editor: { type: 'text' }},  
                   { display: '抓取时间', name: 'grabDate',width : 150,editor: { type: 'text' }
                   },
                   { display: '出错时间', name: 'excuteTime',width : 150,editor: { type: 'text' },
                 	  	render:function(rowdata){
                   		var s= rowdata.excuteTime;
                   		if(s==null){
                   			return;
                   		}
                   		return s.replace("T"," ");
                   }},   
                   
                   { display: '错误类', name:'errorClass',editor:{type:'text'}},
                   { display: '开始rowkey', name:'startRowKey',editor:{type:'text'}},
                   { display: '结束rowkey', name:'endRowkey',editor:{type:'text'}},
                   { display: '操作',  width: 120, render: function (rowdata, rowindex, value)
                     {
                         var param = '"' + rowdata.id + '"';
                         var h = "<a href='javascript:openDetailsPage(" + param + ")'>查看</a> ";
                         return h;
                     }
                 }
                 ], 
           enabledEdit: false, clickToEdit: false, 
           parms : [
                          {name:"code",value: $("#code_ID").val()},
                   	   {name:"start",value: $("#start_ID").val()},
                   	   {name:"end",value: $("#end_ID").val()},
                          ],
           url:"<%=contextPath %>/preprocess-FetlErrorMessage-pageJson.action",
           width: '100%',
    });
	 g.toggleCol("id",false);//隐藏id列
	 return g;
 }
}


//查询方法
function searchAction(){
	
     //form validate
   if(!Validator.Validate(document.getElementById("searchForm"),3))return;
//	var param=$("#searchForm").serialize();
	g = $("#maingrid").ligerGrid({
        checkbox:true,
        height : '100%',
        rowHeight: 28,//行默认的高度
        headerRowHeight: 30,//表头行的高度
        pageSize : 20,
        onToNext:next,//条件查询方法
        newPage:'1',
        columns: [
                  { display: '预处理类型', name: 'fetlName', width : 160, editor: { type: 'text' }},  
                  { display: '抓取时间', name: 'grabDate',width : 150,editor: { type: 'text' }
                  },
                  { display: '出错时间', name: 'excuteTime',width : 150,editor: { type: 'text' },
                	  	render:function(rowdata){
                  		var s= rowdata.excuteTime;
                  		if(s==null){
                  			return;
                  		}
                  		return s.replace("T"," ");
                  }},   
                  
                  { display: '错误类', name:'errorClass',editor:{type:'text'}},
                  { display: '开始rowkey', name:'startRowKey',editor:{type:'text'}},
                  { display: '结束rowkey', name:'endRowkey',editor:{type:'text'}},
                  { display: '操作',  width: 120, render: function (rowdata, rowindex, value)
                    {
                        var param = '"' + rowdata.id + '"';
                        var h = "<a href='javascript:openDetailsPage(" + param + ")'>查看</a> ";
                        return h;
                    }
                }
       ], 
       enabledEdit: false, clickToEdit: false, 
       parms : [
                {name:"code",value: $("#code_ID").val()},
         	   {name:"start",value: $("#start_ID").val()},
         	   {name:"end",value: $("#end_ID").val()},
                ],
       url:"<%=contextPath %>/preprocess-FetlErrorMessage-pageJson.action",
       width: '100%',

   });
	//gridManager.loadServerData(param);/*执行服务器查询*/
}

/*分页条件查询参数*/
function next(){
	gridManager.setOptions({
        parms: [
	   {name:"code",value: $("#code_ID").val()},
	   {name:"start",value: $("#start_ID").val()},
	   {name:"end",value: $("#end_star").val()},
       {}
        ]
    });
}



function openDetailsPage(id){
	var url = "<%=contextPath %>/preprocess-FetlErrorMessage-view.action?id="+id;
	_dialog = jQuery.ligerDialog.open({
  	    title: '查看',
  	    url:url,
  	    isResize: true,
  	    width: 850, 
  	    height: 500, 
  	    isHidden: false
      });
}
</script>
</head>
<body>
<div style="width:98%;height:100%;padding-left: 5px;">
<!-- search form -->
<form name="searchForm" id="searchForm" target="_self">
<table border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>
<table width="800" border="0" style="margin:5px">
 <tr height="25px">
 
  <td width="12%">预处理:</td>
  <td width="21%">
    <select name="code"  id="code_ID" class="select-common">
	</select> 
  </td>
 
   <td width="12%"> 抓取时间：</td>
   <td width="22%">
				<input name="start" type="text"	id="start_ID" style="width: 180px"    
							onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH'})" readonly="readonly"/>
	</td>
    <td width="12%"> 结束时间：</td>
	<td width="22%">
				<input name="end" type="text"	id="end_ID" style="width: 180px"    
							onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH'})" readonly="readonly"/>
	</td>		

 </tr>
</table>	
</td>
    <td><input id="searchButton" type="button" class="btn-normal" onclick="searchAction()" value="查询" /></td>
  </tr>
</table>	
</form>
<!-- grid -->
<div id="maingrid"></div> 
</div>
</body>
</html>
